import time

import selenium
from selenium.webdriver import chrome
from selenium.webdriver.common.by import By

ui='http://106.52.182.140/fanwe/'#进入方唯
dr=selenium.webdriver.Chrome()
dr.get(url=ui)#使用GET请求
dr.maximize_window()#浏览器最大化窗口
# dr.minimize_window()#最小化窗口
dr.implicitly_wait(15)#设置隐式等待
# dr.set_window_size(500,1000)#设置窗口的大小
dr.find_element(By.ID,"login-email-address").send_keys("小可爱")#输入账号
dr.find_element(By.ID,"login-password").send_keys("a12345")#输入密码
dr.find_element(By.ID,"Iajax-login-submit").click()#点击登录
# time.sleep(2)#等待2秒
xp="//*[@id='fanwe_msg_box']/table/tbody/tr/td[2]/div[3]/input[2]"#提取取消的xpath
dr.find_element(By.XPATH,xp).click()#点击取消
time.sleep(1)#等待一秒

dr.find_element(By.XPATH,"/html/body/div[1]/div[2]/div/ul/li[8]/a").click()#进入后台管理
dr.find_element(By.CLASS_NAME,"adm_name").send_keys("admin")#输入用户名
dr.find_element(By.CLASS_NAME,"adm_password").send_keys("admin")#输入密码
dr.find_element(By.CLASS_NAME,"adm_verify").send_keys("t")
dr.find_element(By.ID,"login_btn").click()#点击登录

dr.switch_to.frame("top")#切换到借贷管理的frame
dr.find_element(By.XPATH,"//*[@id='navs']/ul/li[2]/a").click()#点击借贷管理
time.sleep(3)
dr.find_element(By.XPATH,"//*[@id='navs']/ul/li[1]/a").click()#点击首页
time.sleep(2)
dr.switch_to.default_content()#退出盒子，切换至默认页面
dr.switch_to.frame("menu")#切换到网站统计的frame
dr.find_element(By.XPATH,"/html/body/dl[1]/dd[2]/a").click()